import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_study_app/widget/my_underline_tab_indicator.dart';

class TabAppBar extends StatefulWidget implements PreferredSizeWidget{
  final List<Widget> tabs;
  final TabController tabController;

  TabAppBar({required this.tabs,required this.tabController});

  @override
  State<StatefulWidget> createState() => _TabAppBarState();

  @override
  Size get preferredSize => Size.fromHeight(45);
}

class _TabAppBarState extends State<TabAppBar>{
  @override
  Widget build(BuildContext context) {
    var back=InkWell(
      onTap: (){

      },
      child: Padding(
        padding: EdgeInsets.all(12),
        child: Image.asset('assets/images/ic_back.png'),
      ),
    );


    return AnnotatedRegion<SystemUiOverlayStyle>(
        value: SystemUiOverlayStyle.dark,
        child: SafeArea(
          child: Container(
            child: Stack(
              children: [
                back,
                Center(
                  child: Container(
                    height: 30,
                    child: TabBar(
                      indicatorColor: Color(0xff009669),
                      labelColor: Color(0xff009669),
                      labelStyle: TextStyle(fontSize: 15),
                      unselectedLabelColor: Color(0xff333333),
                      unselectedLabelStyle: TextStyle(fontSize: 15),
                      labelPadding: EdgeInsets.only(left: 10,right: 10),
                      isScrollable: true,
                      indicator: MyUnderlineTabIndicator(borderSide: BorderSide(width: 2.0,color: Color(0xff009669))),
                      tabs: widget.tabs,
                      controller: widget.tabController,
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
    );
  }
  
}